/**
 * Copyright (c) 2010-2011 Pierre Labatut
 *
 * This file is part of Space-Chronicles project.
 *
 * Space-Chronicles is free software: you can redistribute it and/or modify it
 * under the terms of its license which may be found in the accompanying
 * LICENSE file or <http://code.google.com/p/space-chronicles/>.
 */

package space.game;

import java.util.HashSet;
import java.util.Set;
import jinngine.physics.Body;
import jinngine.physics.DefaultDeactivationPolicy;

/**
 *
 * @author Pierre
 */
public class InteractiveDesactivationPolicy extends DefaultDeactivationPolicy {

    final private Set<Body> allwaysActive = new HashSet<Body>();

    public void setAllwaysActive(Body b) {
        allwaysActive.add(b);
    }
    
    @Override
    public boolean shouldBeActivated(Body b, double dt) {
        if (allwaysActive.contains(b)) {
            return true;
        }
        return super.shouldBeActivated(b, dt);
    }
    
    @Override
    public boolean shouldBeDeactivated(Body b, double dt) {
        if (allwaysActive.contains(b)) {
            return false;
        }
        return super.shouldBeDeactivated(b, dt);
    }
}
